package com.sanben.category.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sanben.category.data.req.CategoryReq;
import com.sanben.category.entity.Category;
import com.sanben.category.mapper.CategoryMapper;
import com.sanben.category.service.ICategoryService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author cyh
 * @description: 类别分类表 服务实现类
 * @date: 2020-08-11
 */
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements ICategoryService {

    @Override
    public List<Category> getHomeList(CategoryReq req) {
        LambdaQueryWrapper<Category> lambdaQuery = new LambdaQueryWrapper<>();
        lambdaQuery.orderByDesc(Category::getSort)
                .eq(Category::getStatus, req.getStatus())
                .last("limit 6");
        return this.list(lambdaQuery);
    }

}
